package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：白彦东
 * 创建时间：二〇一七年一月九日 13:42:55
 * 修改备注：
 * ================================================
 */
public class BusinessMerchant {

    /**
     * 商户信息
     *
     * @param activity
     * @param useraccId 商户ID
     * @param handler
     */
    public static void getMerchantByUserAccId(Activity activity, String useraccId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("useraccId", useraccId);

        OkHttpUtil.post(activity, URL.URL_GET_MERCHANT_BY_USER_ID, "", params, handler,
                MSG.MSG_GET_MERCHANT_BY_USER_ID_SUCCESS, MSG.MSG_GET_MERCHANT_BY_USER_ID_FIELD);

    }

    /**
     * 商户主页接口
     *
     * @param activity
     * @param merchantId 商户ID
     * @param handler
     */
    public static void showMerchantHome(Activity activity, String merchantId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("merchantId", merchantId);

        OkHttpUtil.post(activity, URL.URL_SHOW_MERCHANT_HOME, "", params, handler, MSG.MSG_SHOW_MERCHANT_HOME_SUCCESS, MSG.MSG_SHOW_MERCHANT_HOME_FIELD);

    }


    /**
     * 查询所有商品
     *
     * @param activity
     * @param merchantId 传入商户ID查询的是当前商户的商品信息，不传查询所有
     * @param offset
     * @param limit
     * @param handler
     */
    public static void getAllGoods(Activity activity, String merchantId, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("merchantId", merchantId);
        params.put("type", "1"); //type       类型(1所有/2精选)
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_ALL_AND_HAND_PICK, "", params, handler, MSG.MSG_GET_ALL_GOODS_SUCCESS, MSG.MSG_GET_ALL_GOODS_FIELD);

    }

    /**
     * 查询精选商品
     *
     * @param activity
     * @param merchantId
     * @param offset
     * @param limit
     * @param handler
     */
    public static void getQualityGoods(Activity activity, String merchantId, String offset, String limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("merchantId", merchantId);
        params.put("type", "2"); // type       类型(1所有/2精选)
        params.put("offset", offset);
        params.put("limit", limit);

        OkHttpUtil.post(activity, URL.URL_GET_ALL_AND_HAND_PICK, "", params, handler, MSG.MSG_GET_QUALITY_GOODS_SUCCESS, MSG.MSG_GET_QUALITY_GOODS_FIELD);

    }
}
